package com.fenyin.samples.study.parttern.struct.bridge.example1;  

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class DriverManager {
	
	private static final Log log = LogFactory.getLog(DriverManager.class);
	
	private static List<Driver> driverList = new ArrayList<Driver>();
	
	public static void registerDirver(Driver driver){
		driverList.add(driver);
	}
	
	public static Connection getConnection(String url,String userName,String password){
		return driverList.get(0).getConnection(url, userName, password);
	}
	
	public static void main(String[] args){
		try{
			Class.forName("com.bj58.samples.study.parttern.struct.bridge.example1.mysql.MySqlDriver");
			Connection conn = DriverManager.getConnection("mysql://localhost:3306", "fengzhichao", "12345");
			Statement statement = conn.getStatement();
			statement.executeSql("select * from t_info");
		}catch(Throwable th){
			log.error(th);
		}
		
	}
}
